Every Element
The Every Element reference form specifies every object of a particular class in a container.SYNTAX
every className pluralClassNamewhereclassName is a singular class name (such as word or paragraph).
pluralClassName is the plural form defined by AppleScript or an application (such as
words
orparagraphs
). The plural form of an object class name has the same effect as the wordevery
before an object class name. Plural forms are listed in application dictionaries.VALUE
The value of an Every Element reference is a list of the objects in the container. If the container does not contain any objects of the specified class, the list is an empty list. For example, the value of the expression
every paragraph of {1, 2, 3}is the empty list:
{}EXAMPLES
The following example assigns a string to the variablemyString
, and then uses the Every Element reference form to specify every word contained in
the string.
set myString to "That's all, folks"every word of myStringThe value of the referenceevery word of myString
is a list with
three items:
{"That's", "all", "folks"}The following reference specifies the same list:
words of myStringThe following references specify a list of all the words in the first paragraph of a document.
tell front document of application "Scriptable Text Editor" every word of paragraph 1 words of paragraph 1 end tellNOTES
If you specify an Every Element reference as the container for a property or object, the result is a list containing the specified property or object for each object of the container. The number of items in the list is the same as the number of objects in the container. For example, the value of the reference
length of every wordis a list such as
{ 2, 3, 6 }The first item in the list is the length of the first word, the second item is the length of the second word, and so on.